<?php
//http://www.php.ru/manual/language.oop5.decon.html
class MessageBroker{
	// Hold an instance of the class
	private static $instance;

	private $sessionManager = NULL;
	private $authenticationManager = NULL;
	private $dispatcher = NULL;

	// The singleton method
	public static function getInstance()
	{
        	if (!isset(self::$instance)) {
        		    $c = __CLASS__;
        		    self::$instance = new $c;
        	}
		return self::$instance;
	}


	private function __construct() {
		$this->sessionManager = new SessionManager();
		$this->authenticationManager = new AuthenticationManager();
		//$this->dispatcher = new Dispatcher();
    	}

	public function __destruct() {
	}

	public function __sleep()
	    {
//	        mysql_close($this->link);
	    }
    
  	  public function __wakeup()
  	  {
  //	      $this->connect();
  	  }


	public function getSessionManager() {
		return $this->sessionManager;
	}
	
	public function getDispatcher() {
		return $this->dispatcher;
	}
	
	public function getAuthenticationManager() {
		return $this->authenticationManager;
	}

	public function startup() {
		$this->sessionManager->start();
		$this->dispatcher->start();
	}
	
	public function shutdown() {
		$this->dispatcher->stop();
		$this->sessionManager->stop();
	}
}
?>
